home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
echsys10.zip
/
ECHOSYS.ASM
next >
Wrap
Assembly Source File
|
1989-09-25
|
23KB
|
557 lines
; EchoSys : show current system data (drive, dir, time, date etc)
; for redirection purposes
;
; Version 1.0
;
; Free Software by TapirSoft Gisbert W.Selke, Sept 1989
;
; This programme may be used and copied any way you wish, except don't
; sell it. Give credit where credit is due, please. - The copyright remains
; with me; I do not guarantee proper operation of this utility; the whole
; risk of use lies with the user.
;
; Usage: echosys <string>
; String is echoed to stdout; two-char sequences introduced by '^'
; are replaced as indicated at 'Usage' below.
;
; TASM echosys or MASM echosys
; TLINK /t echosys LINK echosys
; EXEBIN echosys.exe echosys.com
BackSpace Equ 08h
LineFeed Equ 0Ah
Return Equ 0Dh
CtrlZ Equ 1Ah
DisplayAL Macro ; macro to echo the
Mov dl, al ; contents of AL to stdout
Mov ah, 02h
Int 21h
Endm
DisplayChar Macro Chr ; macro to echo a character
Mov dl, Chr ; character to stdout
Mov ah, 02h
Int 21h
Endm
Jmps Macro Label ; Jump short
Jmp short Label
Endm
cseg Segment
Org 0080h
Parameter Db ?
Org 100h
Assume CS:cseg, DS:cseg, ES:cseg
Start: Jmp Begin
db 'SPECIAL='
Special db '^'
db Return
Copyright db 'EchoSys 1.0 - Free software by TapirSoft'
db ' Gisbert W.Selke, Sept 89', Return, LineFeed
db 'Use at your own risk.$', BackSpace, ' '
db Return, LineFeed, CtrlZ
Usage1 db Return, LineFeed, LineFeed
db 'Usage: echosys <string>', Return, LineFeed
db 'The string is echoed to stdout with "$'
Usage2 db '@" replaced as indicated by @:', Return, LineFeed
db ': drive; \ directory; F free disk space; '
db 'T total disk space; R free RAM;', Return, LineFeed
db 'r RAM size; l #drives; f #floppies; P #printers; '
db 'S #serial ports;', Return, Linefeed
db '7 coprocessor? L LPT1 status; V video mode; '
db 'w screen width; t type of PC;', Return, LineFeed
db 'v DOS version; b BIOS version; i "<" symbol; '
db 'o ">" symbol; p "|" symbol; ', Return, LineFeed
db 'O switch char; A author''s note; '
db 'x char given by next 2 hex digits;', Return, LineFeed
db 'K key typed by user; C country code; $'
Usage3 db ' currency string;', Return, LineFeed
db 'k 1000s separator; 1 decimal separator; '
db '/ date separator; - time separator;'
db Return, LineFeed
db 'D day; M month; Y year; W weekday; h hour; m minute; '
db 's second; c centisecond.'
db Return, LineFeed, Return, LineFeed, '$'
RetVal db 0
ModelString db '??80AP30??ATJRXTPC'
ModelStrLen Label Byte
CmdLetters db 'csmhWYMD-/1k$CpoiKxAObvtwVL7SPflRrTF\:';command letters
EndCmdLetters Label Word
; **NOTE**: order of CmdLetters and Dispatch is reversed w.r.t. each other!
Dispatch dw Drive, Directory, FreeSpace, TotalSpace, MemSize
dw FreeMem, LogicDrives, Floppies, Printers
dw CommPorts, Coproc, LptStat, VideoMode, VideoWidth
dw SysModel, DosVersion, BiosVersion, SwitchChar, Author
dw Hexnumber, KeyBoard
dw StdInSymbol, StdOutSymbol, PipeSymbol, CountryInfo
dw Currency, Thousands, Decimal, DateSep, TimeSep
dw Day, Month, Year, WeekDay
dw Hour, Minute, Second, CentiSecond
Begin: Mov sp, Offset OurStack ; point to our own stack
Mov bx, Offset ProgEnd + 15 ; pointer to end of programme
Mov cl, 4 ; convert size to paragraphs
ShR bx, cl
Mov ah, 4Ah ; return unused memory to DOS
Int 21h
Mov ah, 2Ch ; get current time right now
Int 21h
Mov [TimeBuf], ch ; stow away
Mov [TimeBuf+1], cl
Mov [TimeBuf+2], dh
Mov [TimeBuf+3], dl
Mov ah, 2Ah ; get current date
Int 21h
Sub cx, 1900 ; remove centuries
Mov word ptr [DateBuf], cx ; stow away
Mov [DateBuf+2], dh
Mov [DateBuf+3], dl
Mov [DateBuf+4], al
Mov si, 1+offset Parameter ; command line string
Lodsb
Cmp al, ' ' ; skip first char, if
Je NextChar ; blank or tab
Cmp al, 09h
Je NextChar
Cmp al, Return
Jne CheckSpecials
Mov dx, offset Copyright ; show author's note
Mov ah, 09h
Int 21h
Mov dx, offset Usage1 ; show usage hints
Mov ah, 09h
Int 21h
DisplayChar Special
Mov dx, offset Usage2 ; more usage hints
Mov ah, 09h
Int 21h
DisplayChar '$'
Mov dx, offset Usage3 ; more usage hints
Mov ah, 09h
Int 21h
Mov [RetVal], 0FFh ; termination code
Jmps Done
NextChar: Lodsb
Cmp al, Return ; are we done?
Jne CheckSpecials
Done: Mov ah, 4Ch ; terminate normally
Mov al, [RetVal] ; return code
Int 21h
CheckSpecials: Cmp al, Special ; is it special sequence?
Je DoSpecials
CheckSp2: DisplayAL ; otherwise just display it
Jmps NextChar ; and loop
DoSpecials: Lodsb ; get next char of sequence
Mov di, offset CmdLetters ; look up in table
Mov cx, (offset EndCmdLetters) - (offset CmdLetters)
Repne Scasb
Jz DoSp2 ; jump if found
Cmp al, Return ; otherwise: are we done?
Je Done
Jmps CheckSp2 ; otherwise treat normal
DoSp2: Add cx, cx ; double for Word
Mov bx, cx
Call [dispatch+bx] ; call the subroutine
Jmps NextChar
Drive: Mov ah, 19h ; get current drive
Int 21h
Add al, 41h ; convert to ASCII
Mov [RetVal], al ; store for return
DisplayAL ; and show it
DisplayChar ':' ; and a colon
Ret
Directory: Mov c